package pers.cj.pdos.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import pers.cj.pdos.cache.CacheData;
import pers.cj.pdos.cache.CacheRemove;
import pers.cj.pdos.constant.CacheConstant;
import pers.cj.pdos.entity.BusinessSet;
import pers.cj.pdos.mapper.BusinessSetMapper;
import pers.cj.pdos.service.IBusinessSetService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 包含基本信息设置、常用设置、税率设置、移动支付设置（微信和支付宝） 服务实现类
 * </p>
 *
 * @author chenj
 * @since 2019-11-04
 */
@Service
public class BusinessSetServiceImpl extends ServiceImpl<BusinessSetMapper, BusinessSet> implements IBusinessSetService {
    @Autowired
    BusinessSetMapper businessSetMapper;
    @Override
    @CacheData(clazz = BusinessSetServiceImpl.class, param = "#companyId")
    public BusinessSet getByCompany(String companyId) {
        return businessSetMapper.selectOne(new QueryWrapper<BusinessSet>().eq("company_id",companyId));
    }

    @Override
    @CacheRemove(clazz = BusinessSetServiceImpl.class, methodName = "getByCompany", param = "#businessSet.companyId")
    public void update(BusinessSet businessSet) {
        businessSetMapper.updateById(businessSet);
    }
}
